package net.siufung.mybatis.base;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import net.siufung.core.model.AbstractDto;
import net.siufung.core.utils.ValidationUtil;
import net.siufung.core.utils.ValidationUtil.ValidResult;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * 分页基础模型
 * @author 陈建峰
 * @since 2022/2/9 11:37 下午
 */
@Slf4j
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="BasePageModel", description="分页基础实体")
public class BasePageModel extends AbstractDto {

    private static final long serialVersionUID = -1555021500524398469L;

    /**
     * 当前页
     */
    @ApiModelProperty(value = "当前页")
    @Min(value = 1, message = "当前页最小为1")
    @NotNull(message = "当前页不能为空!")
    private Integer pageNo;

    /**
     * 每页显示条数
     */
    @ApiModelProperty(value = "每页显示条数")
    @Max(value = 1000, message = "每页显示条数最大为1000")
    @NotNull(message = "每页显示条数不能为空!")
    private Integer pageSize;

    @Override
    public ValidResult validResult() {
        return ValidationUtil.validateBean(this);
    }
}
